package com.lemon.smartsafetynew.util.record;

import com.lemon.smartsafetynew.util.common.AppSharePreferenceUtil;
import com.lemon.smartsafetynew.util.constants.SafeCloudConstants;

/**
 * Created by Andrew on 2018/1/11.
 */

public class RecordUtils {

    /**
     * 保存网格点搜索历史记录
     *
     * @param userId
     * @param source
     */
    public static void saveGridSearchHistory(String userId, String source) {
        AppSharePreferenceUtil
                .getInstance()
                .putString(SafeCloudConstants.GRID_SEARCH_HISTORY + SafeCloudConstants.CONCAT_STRING + userId, source);
    }

    /**
     * 获取网格点搜索历史记录
     *
     * @return
     */
    public static String getGridSearchHistory(String userId) {

        return AppSharePreferenceUtil
                .getInstance()
                .getString(SafeCloudConstants.GRID_SEARCH_HISTORY + SafeCloudConstants.CONCAT_STRING + userId, null);
    }

    /**
     * 移除网格点搜索历史记录
     *
     * @return
     */
    public static void removeGridSearchHistory(String userId) {

        AppSharePreferenceUtil
                .getInstance()
                .remove(SafeCloudConstants.GRID_SEARCH_HISTORY + SafeCloudConstants.CONCAT_STRING + userId);
    }

    /**
     * 保存企业搜索历史记录
     * @param userId
     * @param gridId
     * @param source
     */
    public static void saveCompanySearchHistory(String userId, String gridId, String source) {
        AppSharePreferenceUtil
                .getInstance()
                .putString(SafeCloudConstants.COMPANY_SEARCH_HISTORY + SafeCloudConstants.CONCAT_STRING + userId
                        + SafeCloudConstants.CONCAT_STRING + gridId, source);
    }

    /**
     * 获取企业搜索历史记录
     * @param userId
     * @param gridId
     * @return
     */
    public static String getCompanySearchHistory(String userId, String gridId) {

        return AppSharePreferenceUtil
                .getInstance()
                .getString(SafeCloudConstants.COMPANY_SEARCH_HISTORY + SafeCloudConstants.CONCAT_STRING + userId
                        + SafeCloudConstants.CONCAT_STRING + gridId, null);

    }

    /**
     * 移除企业搜索历史记录
     * @param userId
     * @param gridId
     */
    public static void removeCompanySearchHistory(String userId, String gridId) {
        AppSharePreferenceUtil
                .getInstance()
                .remove(SafeCloudConstants.COMPANY_SEARCH_HISTORY + SafeCloudConstants.CONCAT_STRING + userId
                        + SafeCloudConstants.CONCAT_STRING + gridId);

    }

    /**
     * 保存当前用户网格点数据
     *
     * @param userId
     * @param source
     */
    public static void saveGridData(String userId, String source) {
        AppSharePreferenceUtil
                .getInstance()
                .putString(SafeCloudConstants.GRID_TREE_DATA + SafeCloudConstants.CONCAT_STRING
                        + userId, source);
    }

    /**
     * 获取当前用户网格点数据
     *
     * @param userId
     */
    public static String getGridData(String userId) {

        return AppSharePreferenceUtil
                .getInstance()
                .getString(SafeCloudConstants.GRID_TREE_DATA + SafeCloudConstants.CONCAT_STRING
                        + userId, null);

    }


}
